package com.heima.user.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.model.user.vos.UserLoginSuccessVo;
import com.heima.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 *
 * @author liudo
 * @version 1.0
 * @project heima-leadnews
 * @date 2023/11/3 11:18:12
 */
@RestController
@RequestMapping("/api/v1/login")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    /**
     * 登录
     *
     * @param apUser ap用户
     * @return {@link ResponseResult}<{@link UserLoginSuccessVo}>
     */
    @PostMapping("/login_auth")
    public ResponseResult<UserLoginSuccessVo> login(@RequestBody ApUser apUser) {
        UserLoginSuccessVo userLoginSuccessVo = userService.login(apUser);
        return ResponseResult.okResult(userLoginSuccessVo);
    }
}
